<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .font {
        font-size: 30px;
        font-weight: 900;
      }
      .red {
        color: red;
      }
      .center {
        text-align: center;
      }
      .bgred {
        background-color: red;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <h2>class</h2>
      <!-- <p :class="show ? 'font' : ''">class样式</p> -->

      <!-- 对象语法 -->
      <!-- key是对应的类名， value是变量或者表达式 -->
      <!-- class和:class是可以一起存在的 -->
      <p :class="{ font: show, red: num === 1 }" class="center">class样式</p>
      <button @click="show = !show">btn</button>

      <hr />

      <ul>
        <li
          v-for="(item, index) in list"
          :class="{ bgred: index === active }"
          @click="active = index"
        >
          {{ item }}
        </li>
      </ul>
    </div>

    <script src="../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          show: true,
          num: 1,
          list: ["1111111111111", "222222222222", "3333333333333"],
          active: 0,
        },
      });
    </script>
  </body>
</html>
